
package STC;

import java.io.FileInputStream;
import java.util.Scanner;

public class STC4lv3 {

    static int test_case;
    static char[][] C;
    static final int SIZE = 100;

    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        sc = new Scanner(new FileInputStream("input4.txt"));
        for (int test_case = 1; test_case <= 10; test_case++) {
            int N = sc.nextInt();

            C = new char[SIZE][SIZE];
            for (int i = 0; i < SIZE; i++) {
                String s = sc.next();
                for (int j = 0; j < SIZE; j++) {
                    C[i][j] = s.charAt(j);
                }
            }

            int mSize = SIZE;
            int max = Integer.MIN_VALUE;
            StringBuffer str = new StringBuffer();
            String out = "";
            boolean f = true;
            
            while (mSize > 0 && f) {
             // duyet hang ngang
                for (int i = 0; i < SIZE; i++) {
                    for (int j = 0; j <= SIZE - mSize; j++) {
                        str = new StringBuffer();
                        int l = 0;
                        while (l < mSize) {
                            str.append(C[i][l + j]);
                            l++;
                        }
                        String re = new String(str.toString());
                        if (str.reverse().toString().equals(re)) {
//                            out = re;
                            max = mSize;
                            f = false;
                            break;
                        }
                    }
                }
                // duyet hang doc
                for (int i = 0; i < SIZE; i++) {
                    for (int j = 0; j <= SIZE - mSize; j++) {
                        str = new StringBuffer();
                        int l = 0;
                        while (l < mSize) {
                            str.append(C[l + j][i]);
                            l++;
                        }
                        String re = new String(str.toString());
                        if (str.reverse().toString().equals(re)) {
//                            out = re;
                            max = mSize;
                            f = false;
                            break;
                        }
                    }
                }
                mSize--;
            } // end whle

            System.out.println("#" + test_case + " " + max);

        }// end for test_case
    }
}
